#region Using directives
using System;
using Microsoft.DirectX;
using SharpWind.Resources.Meshes;
using Direct3D = Microsoft.DirectX.Direct3D;
#endregion

namespace SharpWind.Math
{
	public class BoundingSphere
	{
		#region Fields

		private Vector3 center = Vector3.Empty;

		private float radius = 0f;

		#endregion

		#region Constructor

		public BoundingSphere( Vector3 center, float radius )
		{
			this.center = center;
			this.radius	= radius;
		}

		#endregion

		#region Methods

		public static BoundingSphere ComputeFromMesh( Mesh mesh )
		{
			Vector3 center;
			float radius = Direct3D.Geometry.ComputeBoundingSphere( mesh.DxMesh.VertexBuffer.Lock( 0, 0, Direct3D.LockFlags.None ),
																	0, 0, out center );

			return new BoundingSphere( center, radius );
		}

		#endregion

		#region Properties

		public Vector3 Center
		{
			get
			{
				return this.center;
			}
			set
			{
				this.center = value;
			}
		}

		public float Radius
		{
			get
			{
				return this.radius;
			}
			set
			{
				this.radius = value;
			}
		}

		#endregion
	}
}